From: Florian Müllner Date: Wed, 5 Oct 2011 22:16:46 +0000 (+0200) Subject: shell-app: Improve prefix matches X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~7464 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=c427bba9f120aa5881edb4f3faadc6cd3afc8847;p=gnome-shell.git shell-app: Improve prefix matches Currently we use a very strict definition of "prefix", where the search term has to match at the very beginning of the searched criteria (application name, executable name). Use a more liberal definition by including matches where the preceding character is a space (application name) or hyphen (executable name) as well; as many applications use a prefix, this should improve the quality of results. https://bugzilla.gnome.org/show_bug.cgi?id=623372 --- diff --git a/src/shell-app.c b/src/shell-app.c index 105585730..e6e31df09 100644 --- a/src/shell-app.c +++ b/src/shell-app.c @@ -1255,15 +1255,18 @@ _shell_app_match_search_terms (ShellApp *app, current_match = MATCH_NONE; p = strstr (app->casefolded_name, term); - if (p == app->casefolded_name) - current_match = MATCH_PREFIX; - else if (p != NULL) - current_match = MATCH_SUBSTRING; + if (p != NULL) + { + if (p == app->casefolded_name || *(p - 1) == ' ') + current_match = MATCH_PREFIX; + else + current_match = MATCH_SUBSTRING; + } p = strstr (app->casefolded_exec, term); if (p != NULL) { - if (p == app->casefolded_exec) + if (p == app->casefolded_exec || *(p - 1) == '-') current_match = (current_match == MATCH_NONE) ? MATCH_PREFIX : MATCH_MULTIPLE_PREFIX; else if (current_match < MATCH_PREFIX)